layui.use(['element', 'layer','form'], function () {
    var layer = layui.layer
        , form = layui.form;
    form.on('submit(login)', function (data) {

        $.ajax({
            url:'login'
            ,type:'post'
            ,data:data.field
            ,dataType:'json'
            ,success:function (res) {
                if (('error_message' in res)) {
                    layer.msg(res.error_message, {icon: 2,anim:6,time: 2000});
                    return;
                }
                window.location ='/'+ res.url;
                // console.log(res)

            }
        });

        return false;

    });
});


